package com.study.dao;

import com.study.dao.impl.AdminInfoDAOImpl;
import com.study.pojo.AdminInfo;
import org.junit.jupiter.api.Test;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * @PackgeName: com.study.dao
 * @ClassName: AdminInfoTest
 * @Author: 严志祥
 * Date: 2022-05-04 20:31
 * project name: web_project_medal
 * @Version:
 * @Description:
 */
public class AdminInfoTest {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    AdminInfoDAO admin = new AdminInfoDAOImpl();

    @Test
    public void insert() throws ParseException, SQLException {

        admin.insert(new AdminInfo("zhangsan","a123123",sdf.parse("2022-05-04 20:34:22")));
    }

    @Test
    public void update() throws ParseException, SQLException {
        AdminInfo a = new AdminInfo();
        a.setAdminId(1);
        a.setAdminName("lisi");
        a.setAdminPassword("aaaa");
        a.setAdminTime(sdf.parse("2022-05-04 20:39:22"));
        admin.updateById(a);
    }

    @Test
    public void delete() throws SQLException {
        admin.deleteById(1);
    }

    @Test
    public void selectById() throws SQLException {
        AdminInfo adminInfo = admin.selectById(2);
        System.out.println(adminInfo);
    }

    @Test
    public void select() throws SQLException {
        List<AdminInfo> list = admin.select(0, 9);
        System.out.println(list);
    }

    @Test
    public void count() throws SQLException {
        long count = admin.count();
        System.out.println(count);
    }

    @Test
    public void selectByName() throws SQLException {
        AdminInfo adminInfo = admin.selectByName("admin");
        System.out.println(adminInfo);
    }
}